/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package admin.controller;

import admin.provider.ActivityProvider;
import ejb.entity.Activity;
import java.io.Serializable;
import java.util.List;
import javax.enterprise.context.RequestScoped;
import javax.faces.model.SelectItem;
import javax.inject.Named;

/**
 *
 * @author Nothing4ever
 */
@Named(value = "comboBoxModel")
@RequestScoped
public class ComboBoxModel implements Serializable {

    private static final long serialVersionUID = 1L;

    public ComboBoxModel() {
    }

    public SelectItem[] listActivity() {
        List<Activity> listActivity = ActivityProvider.getInstance().findAll();
        SelectItem[] activityOption = new SelectItem[listActivity.size() + 1];

        activityOption[0] = new SelectItem("", "Select activity");
        System.out.println("first:" + listActivity.get(0));
        for (int i = 0; i < listActivity.size(); i++) {
            activityOption[i + 1] = new SelectItem(listActivity.get(i).getId(), listActivity.get(i).getName());
        }
        return activityOption;
    }
}
